﻿@page "/report"

<h3>Report</h3>
<div class="runid-box">
    <label for="RunId">Run ID:</label>
    <select id="RunId" @bind="RunIdInput">
        @for (int i = 0; i < Runs.Count; i++)
        {
            <option value="@i">@Runs[i]</option>
        }
    </select>
</div>
<Results FirstRunId="@Runs[RunIdInput].firstRunId" SecondRunId="@Runs[RunIdInput].secondRunId" AnalysesFile="@Runs[RunIdInput].analysesHash" MonitorRunId="@Runs[RunIdInput].secondRunId"/>
@code {

    List<(string firstRunId, string secondRunId, string analysesHash, RUN_STATUS runStatus)> Runs = AttackSurfaceAnalyzerClient.DatabaseManager.GetCompareRuns();

    private int _runIdInput;

    int RunIdInput
    {
        get
        {
            return _runIdInput;
        }
        set
        {
            appData.ExportCollectCommandOptions.FirstRunId = Runs[value].firstRunId;
            appData.ExportCollectCommandOptions.SecondRunId = Runs[value].secondRunId;
            _runIdInput = value;
            this.StateHasChanged();
        }
    }

    System.Threading.Timer timer;

    protected override void OnInitialized()
    {
        timer = new System.Threading.Timer((_) => InvokeAsync(() => StateHasChanged()), null, 0, 100);
        base.OnInitialized();
    }
}
